﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>ZRender</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="ZRender">
    <meta name="author" content="linzhifeng@baidu.com">

    <script src="../asset/js/esl/esl.js"></script>
    <script src="../asset/js/codemirror.js"></script>
    <script src="../asset/js/javascript.js"></script>

    <link href="../asset/css/bootstrap.css" rel="stylesheet">
    <link href="../asset/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="../asset/css/codemirror.css" rel="stylesheet">
    <link href="../asset/css/monokai.css" rel="stylesheet">
    <link href="../asset/css/zrenderHome.css" rel="stylesheet">
    <link rel="shortcut icon" href="../asset/ico/favicon.png">
</head>

<body>
    <!-- NAVBAR
    ================================================== -->
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="../../index.html">ZRender</a>
          <div class="nav-collapse collapse">
              <a id="forkme_banner" href="https://github.com/ecomfe/zrender">View on GitHub</a>
              <ul class="nav">
                <li><a href="../../index.html"><i class="icon-home icon-white"></i> Home</a></li>
                <li class="active dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Example <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="demo.html">Demo</a></li>
                    <li><a href="animation.html">Animation</a></li>
                    <li class="active"><a href="chart.html">Chart</a></li>
                    <li><a href="colorSeries.html">Color Series</a></li>
                    <li class="divider"></li>
                    <!--li class="nav-header">Library</li-->
                    <li><a href="artist.html">Artist</a></li>
                    <li><a href="slice.html">slice</a></li>
                  </ul>
                </li>
                <li><a href="../doc.html">API &amp; Doc</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt icon-white"></i>Download <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="https://github.com/ecomfe/zrender/archive/2.0.2.zip">ZIP (2.0.2)</a></li>
                    <li><a href="https://github.com/ecomfe/zrender/archive/master.zip">ZIP (Latest)</a></li>
                  </ul>
                </li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Link <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="https://github.com/ecomfe" target="_blank">Ecom-FE</a></li>
                    <li><a href="http://fe.baidu.com/doc/ecom/tech/topic/dv/index.html" target="_blank">Data Visualization</a></li>
                    <li class="divider"></li>
                    <!--li class="nav-header">Library</li-->
                    <li><a href="http://tangram.baidu.com/" target="_blank">Tangram</a></li>
                  </ul>
                </li>
              </ul>
           </div><!--/.nav-collapse -->
        </div><!-- /.container -->
      </div><!-- /.navbar-inner -->
    </div><!-- /.navbar-wrapper -->

    <div class="container-fluid">
        <div class="row-fluid">
            <div id="sidebar-code" class="span4">
                <div class="well sidebar-nav">
                    <div class="nav-header">code
                    <a href="#" onclick="autoResize()" class="icon-resize-full" id ="icon-resize" ></a>
                    </div>
                    <textarea id="code" name="code">
/*
 *  zr has been init like this, just use it!
 *
 *  var zrender = require('zrender');
 *  var zr = zrender.init(document.getElementById('main'));
 */
require(
    [
        'zrender',
        'zrender/tool/color',
        'zrender/shape/Sector'
    ],
    function ( zrender, zrColor, SectorShape) {
        var zr = zrender.init(document.getElementById('main'));
        zr.clear();
        
        var data = [10,13,23,8,35,18];
        var total = 0;
        for (var i = 0, l = data.length; i < l; i++) {
            total += data[i];
        }
        var percent;
        var startAngle = 0;
        var endAngle;
        var x = Math.round(zr.getWidth() / 2);
        var y = Math.round(zr.getHeight() / 2);
        var r0 = 30;
        var r = 100;

        for (var i = 0, l = data.length; i < l; i++){

            percent = data[i] / total;
            endAngle = (percent * 360 + startAngle).toFixed(2) - 0;
            percent = (percent * 100).toFixed(2) + '%';
            zr.addShape(new SectorShape({
                style : {
                    x : x,          // 圆心横坐标
                    y : y,          // 圆心纵坐标
                    r0 : r0,        // 圆环内半径
                    r : r,          // 圆环外半径
                    startAngle : startAngle,
                    endAngle : endAngle,
                    brushType : 'both',
                    color : zrColor.getColor(i),
                    strokeColor : '#fff'
                },
                highlightStyle : {
                    text : percent,
                    textPosition : 'specific',
                    textX : x,
                    textY : y,
                    textAlign : 'center',
                    textBaseline: 'middle',
                    textColor : 'blue',
                    textFont : 'bold 10px verdana'
                },
                clickable : true,
                onclick : function(params) {
                    alert(params.target.highlightStyle.text);
                }
            }))
            startAngle = endAngle;
        }
        zr.render();
    }
);
                    </textarea>
              </div><!--/.well -->
            </div><!--/span-->
            <div id="graphic" class="span8">
                <div id="main" class="main"></div>
                <div>
                    <button onclick="refresh(true)">Refresh ~</button>
                    <span id='wrong-message' style="color:red"></span>
                </div>
            </div><!--/span-->
        </div><!--/row-->
        <hr>
        <!-- FOOTER -->
        <footer>
          <p class="pull-right"><a href="#">Back to top</a></p>
          <p>&copy; 2013 ECOM-FE &middot; <a href="https://github.com/ecomfe/zrender/blob/master/LICENSE.txt" target="_blank">Terms</a> &middot; <a href="../changelog.html" target="_blank">Changelog</a></p>
        </footer>
    </div><!--/.fluid-container-->

    <script src="../asset/js/jquery.js"></script>
    <script src="../asset/js/bootstrap-transition.js"></script>
    <script src="../asset/js/bootstrap-alert.js"></script>
    <script src="../asset/js/bootstrap-modal.js"></script>
    <script src="../asset/js/bootstrap-dropdown.js"></script>
    <script src="../asset/js/bootstrap-scrollspy.js"></script>
    <script src="../asset/js/bootstrap-tab.js"></script>
    <script src="../asset/js/bootstrap-tooltip.js"></script>
    <script src="../asset/js/bootstrap-popover.js"></script>
    <script src="../asset/js/bootstrap-button.js"></script>
    <script src="../asset/js/bootstrap-collapse.js"></script>
    <script src="../asset/js/bootstrap-carousel.js"></script>
    <script src="../asset/js/bootstrap-typeahead.js"></script>
    <script src="../asset/js/zrenderDemo.js"></script>
</body>
</html>